package com.xiaoyu.lingdian.service.impl;

import java.util.Map;
import java.util.List;
import java.util.HashMap;
import com.xiaoyu.lingdian.core.mybatis.page.Page;
import com.xiaoyu.lingdian.core.mybatis.page.PageRequest;
import com.xiaoyu.lingdian.service.CorePartnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xiaoyu.lingdian.core.mybatis.dao.MyBatisDAO;
import com.xiaoyu.lingdian.entity.CorePartner;

@Service("corePartnerService")
public class CorePartnerServiceImpl implements CorePartnerService {

	@Autowired
	private MyBatisDAO myBatisDAO;

	@Override
	public boolean insertCorePartner(CorePartner corePartner) {
		myBatisDAO.insert(corePartner);
		return true;
	}

	@Override
	public boolean updateCorePartner(CorePartner corePartner) {
		myBatisDAO.update(corePartner);
		return true;
	}

	@Override
	public boolean deleteCorePartner(CorePartner corePartner) {
		myBatisDAO.delete(corePartner);
		return true;
	}

	private static final String DELETEBATCH_COREPARTNER_BY_IDS="deleteBatchCorePartnerByIds";
	@Override
	public boolean deleteBatchByIds(List<String> list ) {
		Map<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("list", list);
		myBatisDAO.delete(DELETEBATCH_COREPARTNER_BY_IDS,hashMap);
		return true;
	}

	@Override
	public CorePartner getCorePartner(CorePartner corePartner) {
		return (CorePartner) myBatisDAO.findForObject(corePartner);
	}

	private static final String FIND_COREPARTNER_FOR_LISTS="findCorePartnerForLists";

	@SuppressWarnings("unchecked")
	@Override
	public List<CorePartner> findCorePartnerList() {
		return myBatisDAO.findForList(FIND_COREPARTNER_FOR_LISTS, null);
	}

	private static final String FIND_COREPARTNER_FOR_PAGES="findCorePartnerForPages";

	@SuppressWarnings("unchecked")
	@Override
	public Page<CorePartner> findCorePartnerPage(int pageNum, int pageSize, String crprrName) {
		Map<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("crprrName", crprrName);
		return myBatisDAO.findForPage(FIND_COREPARTNER_FOR_PAGES, new PageRequest(pageNum, pageSize, hashMap));
	}

//<=================定制内容开始==============
//==================定制内容结束==============>

}